    <!--引入顶部公共-->
    {{include file="VIEW_PATH/Common/header.php"}}
	<link rel="stylesheet" type="text/css" href="Public/Home/Css/cart.css"/>
	<script src="Public/Home/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(function(){
			var t=1;
//			input点击事件
			$("#cart #select_all").click(function(){
//				如果T=1让所有input选中如果等于2取消所有
				if(t==1){
					t=2;
					$(".select").attr("checked","checked");
					$(".select input").attr("checked","checked");
					$('.row').css({'background':'#FFF7D2'});
				}else{
					t=1;
					$(".select").removeAttr("checked","checked");
					$('.row').css({'background':'white'});
					$(".select input").removeAttr("checked","checked");
				}				
			})
			$('.add').click(function(){
				val = $(this).parent().find('input')[0].value;
				val++;
				if($(this).parent().parent().find('.select .danxuan').attr("checked")=="checked"){
				var danjia  = $(this).parent().parent().find('.price span').html();	
				var zongjia = $('.buy .word .price i').html();
				var zongjia = parseInt(danjia) + parseInt(zongjia);
				$('.buy .word .price i').html(zongjia);
				}
				$(this).parent().find('input')[0].value = val;
			})
			$('.min').click(function(){
				val = $(this).parent().find('input')[0].value;
				val--;
				if($(this).parent().parent().find('.select .danxuan').attr("checked")=="checked"){
				var danjia  = $(this).parent().parent().find('.price span').html();	
				if(val==0) danjia = 0;
				var zongjia = $('.buy .word .price i').html();								
				var zongjia = parseInt(zongjia) - parseInt(danjia);											
				$('.buy .word .price i').html(zongjia);		
				}
				if(val==0){
					$(this).parent().find('input')[0].value = 1;
					return;
				}
				$(this).parent().find('input')[0].value = val;
			})
		})
	</script>
	<script type="text/javascript">
		$(function(){
			$('.add').click(function(){				
			    var num = $(this).parent().parent().find('.num input')[0].value;
			    var price = $(this).parent().parent().find('.price span').html();
			    var total = num * price;
			    var sid = $(this).parent().parent().find('#sid').val();
			    var _this = $(this);
				$.ajax({
					type:"post",
					url:"{{U('getAjaxattr')}}",				
					data:{num:num,sid:sid},
					dataType:'json',
					success:function(a){
						if(a==1)
						{
							_this.parent().parent().find('.tot').html(total);
						}						
					}
				});
			})			
			$('.min').click(function(){	
			    var num = $(this).parent().parent().find('.num input')[0].value;
			    var price = $(this).parent().parent().find('.price span').html();
			    var total = num * price;			  
			    var sid = $(this).parent().parent().find('#sid').val();
			    var _this = $(this);
				$.ajax({
					type:"post",
					url:"{{U('getAjaxattr')}}",				
					data:{num:num,sid:sid},
					dataType:'json',
					success:function(a){
						if(a==1)
						{
							_this.parent().parent().find('.tot').html(total);
						}						
					}
				});
			})
			$('.del a').click(function(){
				var _this = $(this);
				var sid = $(this).parent().parent().find('#sid').val();
				if($(this).parent().parent().find('.select .danxuan').attr("checked")=="checked"){
					var price = $(this).parent().parent().find('.tot').html();
					var totalprc = $('.buy .word .price i').html();
					var num = $('.buy .word .num').html();
					totalprc = parseInt(totalprc) - parseInt(price);
					num = parseInt(num) - 1;
					$('.buy .word .price i').html(totalprc);
					$('.buy .word .num').html(num);
				}
				$.ajax({
					type:"post",
					url:"{{U('Ajaxdel')}}",
					data:{sid:sid},
					dataType:'json',
					success:function(a){
						if(a==1)
						{
							_this.parent().parent().remove();
						}
					}
				});
			})
			$('.select').click(function(){
				var price = 0;
				$.each($(".tbody .danxuan"),function(k,v){
				   if($(this).attr("checked")=="checked"){				   		   	
					price += parseInt($(this).parent().parent().find(".tot").html());				
				    }
			    })
			    var total =  $(".tbody").find(".danxuan:checked").length;
			    $('.buy .word .num').html(total);
			    $('.buy .word .price i').html(price);
			})
			$('.alldel').click(function(){				
				if($(".tbody").find(".danxuan:checked").length==0){
					alert("请选择要删除的商品");
				}else{
					var a = "";
					$.each($(".tbody .danxuan"), function(k,v) {
						if($(this).attr("checked")=="checked"){
							a += $(this).attr("sid") + ",";
							$(this).parent().parent().remove();
						}
					});					
					$.ajax({
						type:"post",
						url:"{{U('allDelAjax')}}",
						data:{a:a},
						dataType:'json',
						success:function(phpdata)
						{
							if(phpdata==1)
							{
								$('.buy .word .num').html(0);
			                    $('.buy .word .price i').html(0);
							}
						}
					});
				}
				
			})
		})
	</script>
	<script type="text/javascript">
	$(function(){
		$('.pay').click(function(){
			if($('.tbody').find(".danxuan:checked").length==0){
				alert("请选择您要购买的商品");
			}else{
				var tot = $('.buy .word .price i').html();
				var a="";
				var goods="";
				$.each($('.tbody .danxuan'),function(k,v){
					if($(this).attr("checked")=="checked"){
						a += $(this).attr("sid") + ",";
					}
				})
				$.ajax({
					type:"post",
					url:"{{U('Order/index')}}",
					data:{a:a,tot:tot},
					success:function(phpdata){
						if(phpdata==1)
						{
							location.href='{{U('Order/index')}}';		
						}						
					}
				});
			}
		})
	})		
	</script>
		<div id="flower_header">
				<div class="logo">
				   <a href=""><img src="Public/Home/images/65bc4ebfe22d0c2eca1702c9736c_117_43.ch.png"/></a>
			   </div>	
			   <div class="steps">
			   	<img src="Public/Home/images/cart 1.jpg"/>
			   </div>
		</div>
		{{if value="isset($_SESSION['cart'])"}}
		<div id="status">
			<span class="total">全部商品 (<i>{{$count}}</i>)</span>
		</div>
		<div id="cart">
			<div class="thead">
				<div>
					<input class="select"  type="checkbox" name="" id="select_all" value="" />
					<label class="all" for="select_all">全选</label>
				</div>
				<div>
					<span>商品信息</span>
				</div>
				<div>
					<span class="price">单价（元）</span>
				</div>
				<div>
					<span>数量</span>
				</div>
				<div>
					<span class="total_price">小计（元）</span>
				</div>
				<div>
					<span>操作</span>
				</div>
			</div>
			<div class="tbody">				
				{{foreach from="$cartData" key="$k" value="$v"}}
				<div class="row">
					<input type="hidden" name="sid" id="sid" value="{{$k}}" />
					<div style="height: 121px;" class="select">
						<input style="margin-top: 50px;"  type="checkbox" class="select danxuan" name="" id="sel" value="" sid="{{$k}}"/>
					</div>
					<div class="content">
						<img src="{{$v['image']}}"/>
						<div class="word">
							<p><a href="">{{$v['name']}}</a></p>
							<div class="style">
								{{foreach from="$v['tname']" key="$kk" value="$vv"}}
								<p>{{$vv}}：{{$v['options'][$kk]}}</p>
								{{endforeach}}
							</div>
						</div>
					</div>
					<div class="price">
						<span>{{$v['price']}}</span>
					</div>
					<div class="num">
						<span class="min"></span>
						<input type="text" name="" id="" value="{{$v['num']}}" />
						<span class="add"></span>
					</div>
					<div class="total_price tot">{{$v['total']}}</div>
					<div class="del"><a href="javascript:;">删除</a></div>
				</div>
				{{endforeach}}
			</div>
			<div class="buy">
				<div>
					<input class="select" type="checkbox" name="" id="select_all" value="" />
					<label class="all" for="select_all">全选</label>
					<a class="alldel" href="javascript:;">删除</a>
				</div>
				
				<a class="pay" href="javascript:;">去结算</a>
				<div class="word">
					已选
					<span class="num">0</span>
					件商品,合计(不含运费和优惠扣减):
					<span class="price">￥<i>0</i></span>
				</div>
			</div>			
		</div>
		{{else}}
		<div id="no_logged">
			<div class="clear">
				<div class="icon"></div>
				<div class="word">购物车空空的哦~，去看看心仪的商品吧~</div>
				<a href="" class="login">登录</a>
				<a href="" class="shopping">去逛逛</a>
			</div>
		</div>
		{{endif}}
		<!--引用底部文件-->
		{{include file="VIEW_PATH/Common/footer.php"}}
	</body>
</html>
